// 类型系统模块

pub mod boolean_null_types;
pub mod composite_types;
pub mod function_object_types;
pub mod generic;
pub mod generic_system;
pub mod number_type;
pub mod object_type;
pub mod string_type;
pub mod type_alias;
pub mod type_constraint;
pub mod type_conversion;
pub mod type_hierarchy;

pub use object_type::ObjectType;

pub use boolean_null_types::{BooleanMethods, BooleanUtils, NullMethods};
pub use composite_types::{DictMethods, ListMethods, SetMethods, TupleMethods};
pub use function_object_types::{FunctionMethods, FunctionType};
pub use generic::{GenericInstance, GenericParam, GenericType};
pub use generic_system::{
    GenericParameter, GenericSystem, GenericType as GenericTypeDef, TypeBound,
    TypeConstraint as GenericConstraint, TypeConstraintChecker,
};
pub use number_type::{NumberConverter, NumberMethods, number_constants};
pub use string_type::{StringMethods, StringUtils};
pub use type_alias::TypeAliasManager;
pub use type_constraint::{TypeConstraint, TypeConstraintManager};
pub use type_conversion::{
    ConversionCompatibility, ConversionType, ConversionUtils, TypeConverter,
};
pub use type_hierarchy::{TypeDefinition, TypeHierarchy};

/// 类型系统核心组件
pub struct TypeSystem {
    /// 类型别名管理器
    pub alias_manager: TypeAliasManager,
    /// 类型约束管理器
    pub constraint_manager: TypeConstraintManager,
}

impl TypeSystem {
    /// 创建新的类型系统
    pub fn new() -> Self {
        TypeSystem {
            alias_manager: TypeAliasManager::new(),
            constraint_manager: TypeConstraintManager::new(),
        }
    }

    /// 添加类型别名
    pub fn add_type_alias(&mut self, alias: String, actual_type: String) {
        self.alias_manager.add_alias(alias, actual_type);
    }

    /// 添加类型约束
    pub fn add_type_constraint(&mut self, type_name: String, constraint: TypeConstraint) {
        self.constraint_manager
            .add_constraint(type_name, constraint);
    }

    /// 获取实际类型
    pub fn get_actual_type(&self, type_name: &str) -> String {
        self.alias_manager.get_actual_type(type_name)
    }

    /// 检查类型约束
    pub fn check_constraints(&self, type_name: &str, actual_type: &str) -> bool {
        self.constraint_manager
            .check_constraints(type_name, actual_type)
    }
}
